// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   RoleGroupServiceImpl.java

package com.hfstu.pms.dataaccess.service.impl;

import com.hfstu.framework.core.orm.Page;
import com.hfstu.framework.core.orm.PageRequest;
import com.hfstu.pms.dataaccess.dao.IRoleGroupDao;
import com.hfstu.pms.dataaccess.service.IRoleGroupService;
import com.hfstu.pms.model.RoleGroup;
import java.io.Serializable;
import java.util.*;

public class RoleGroupServiceImpl
	implements IRoleGroupService
{

	private IRoleGroupDao roleGroupDao;

	public RoleGroupServiceImpl()
	{
		roleGroupDao = null;
	}

	public RoleGroup save(RoleGroup roleGroup)
	{
		return (RoleGroup)roleGroupDao.save(roleGroup);
	}

	public RoleGroup update(RoleGroup roleGroup)
	{
		return (RoleGroup)roleGroupDao.update(roleGroup);
	}

	public RoleGroup saveOrUpdate(RoleGroup roleGroup)
	{
		return (RoleGroup)roleGroupDao.saveOrUpdate(roleGroup);
	}

	public void delete(String id)
	{
		roleGroupDao.delete(id);
	}

	public RoleGroup getById(String id)
	{
		return (RoleGroup)roleGroupDao.getById(id);
	}

	public List getByIds(String ids[])
	{
		return roleGroupDao.getByIds(ids);
	}

	public void delete(RoleGroup entity)
	{
		roleGroupDao.delete(entity);
	}

	public List findAll()
	{
		return roleGroupDao.findAll();
	}

	public List findListByCondition(Map filterPropertyMap, Map sortValueMap)
	{
		return roleGroupDao.findListByCondition(filterPropertyMap, sortValueMap);
	}

	public Page findPageByCondition(PageRequest pageRequest, Map filterPropertyMap, Map sortValueMap)
	{
		return roleGroupDao.findPageByCondition(pageRequest, filterPropertyMap, sortValueMap);
	}

	public void deleteAllById(String id)
	{
		List childrenIds = getAllChildrenId(id);
		if (childrenIds != null && childrenIds.size() != 0)
			roleGroupDao.deleteByIds((String[])childrenIds.toArray(new String[childrenIds.size()]));
		roleGroupDao.delete(id);
	}

	public List getAllChildrenId(String id)
	{
		List results = null;
		Map filterPropertyMap = new HashMap();
		filterPropertyMap.put("roleGroup.parentId", id);
		List list = roleGroupDao.findListByCondition(filterPropertyMap, null);
		if (list != null && list.size() != 0)
		{
			results = new ArrayList();
			for (Iterator iterator = list.iterator(); iterator.hasNext();)
			{
				RoleGroup actionGroup = (RoleGroup)iterator.next();
				results.add(actionGroup.getId());
				List childrens = getAllChildrenId(actionGroup.getId());
				if (childrens != null)
					results.addAll(childrens);
			}

		}
		return results;
	}

	public List getAllParentId(String id)
	{
		List results = null;
		RoleGroup actionGroup = (RoleGroup)roleGroupDao.getById(id);
		if (actionGroup != null)
		{
			results = new ArrayList();
			List parentIds = getAllParentId(actionGroup.getParentId());
			if (parentIds != null)
			{
				results.add(actionGroup.getParentId());
				results.addAll(parentIds);
			}
		}
		return results;
	}

	public IRoleGroupDao getRoleGroupDao()
	{
		return roleGroupDao;
	}

	public void setRoleGroupDao(IRoleGroupDao roleGroupDao)
	{
		this.roleGroupDao = roleGroupDao;
	}

	public volatile Object getById(Serializable serializable)
	{
		return getById((String)serializable);
	}

	public volatile Object save(Object obj)
	{
		return save((RoleGroup)obj);
	}

	public volatile Object saveOrUpdate(Object obj)
	{
		return saveOrUpdate((RoleGroup)obj);
	}

	public volatile void delete(Object obj)
	{
		delete((RoleGroup)obj);
	}

	public volatile void delete(Serializable serializable)
	{
		delete((String)serializable);
	}

	public volatile List getByIds(Serializable aserializable[])
	{
		return getByIds((String[])aserializable);
	}

	public volatile Object update(Object obj)
	{
		return update((RoleGroup)obj);
	}
}
